import type {
  AxiosError,
  AxiosInstance,
  AxiosRequestHeaders,
  AxiosResponse,
  InternalAxiosRequestConfig,
} from 'axios';

type AxiosHeaders = 'application/json' | 'multipart/form-data';

type AxiosMethod = 'get' | 'post' | 'delete' | 'put';

type AxiosResponseType =
  | 'arraybuffer'
  | 'blob'
  | 'document'
  | 'json'
  | 'text'
  | 'stream';

/**
 * 自定义的Axios相关基础配置类型
 */
interface AxiosSetting<T = AxiosResponse> {
  baseURL: string;
  code: number;
  defaultHeader: AxiosHeaders;
  timeout: number;
}

/**
 * 自定义的请求调用参数配置类型
 */
interface AxiosConfig {
  params?: any;
  data?: any;
  url?: string;
  method?: AxiosMethod;
  headersType?: string;
  responseType?: AxiosResponseType;
}

/**
 * 自定义的Axios响应对象类型，继承了Axios的响应对象类型
 */
interface IResponse<T = any, D = any> extends AxiosResponse<T, D> {
  code: number;
  message: string;
}

export {
  AxiosConfig,
  AxiosError,
  AxiosInstance,
  AxiosRequestHeaders,
  AxiosResponse,
  AxiosSetting,
  InternalAxiosRequestConfig,
  IResponse,
};
